/**
 * @author 徐楠
 * @date 2022/4/21 9:55
 * @version 1.0
 */

package com.xunan.likou;

public class ReverseString {
    public static void main(String[] args) {
        char[] s = {'h', 'e', 'l', 'l', 'o' };
        reverseString(s);
        for (char c : s) {
            System.out.print(c + " ");
        }
    }

    public static void reverseString(char[] s) {
        int length = s.length;
        for (int i = 0; i < length / 2; i++) {
            char temp = s[i];
            s[i] = s[length - 1 - i];
            s[length - 1 - i] = temp;
        }
    }
}
